import numpy as np
import csv
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

def build_data_list(inputCSV):
    sKey = []
    fn = inputCSV
    ra = csv.DictReader(file(fn), dialect="excel")
    
    for record in ra:
        #print record[ra.fieldnames[0]], type(record[ra.fieldnames[-1]])
        for item in ra.fieldnames:
            temp = float(record[item])
            sKey.append(temp)
    sKey = np.array(sKey)
    sKey.shape=(-1,len(ra.fieldnames))
    return sKey

#--------------------------------------------------------------------------
#MAIN

if __name__ == "__main__":
    unitCSV = 'C:/_DATA/CancerData/test/Jun08/TP1000_1m_16_04.csv'
    ncCSV = 'C:/Documents and Settings/wang322/My Documents/test/satscan/NortheeaternUS.csv'
    dataMatrix = build_data_list(ncCSV)  # [id, pop, cancer1, cancer2, cancer3]
    n, bins, patches = plt.hist(dataMatrix[:,1], 50, normed=1, facecolor='green', alpha=0.75)
    plt.show()
    